﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Business;
using System.Collections;

namespace BVVD_Website
{
    public partial class frmLogin : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            BVVDLibrary bl = new BVVDLibrary();
            BVVDDataContext db = new BVVDDataContext();
            StringComparer sc = StringComparer.Ordinal;
            //condition.Add("","");
            string pass = bl.encryptPassword(txtPassword.Value);
            LST_NSD user = (from nsd in db.LST_NSDs
                            where nsd.MANSD.Equals(txtUsername.Value)  
                            && nsd.MATKHAU.ToString().Equals(pass)
                            select nsd).SingleOrDefault();
            if (user !=null)
            {
                Session["user"] = user;
                Page.Response.Redirect("HomePage.aspx");
            }
            else {
                rnAlert.Text = "Thông tin đăng nhập không chính xác ";
                    rnAlert.Show();
                
            }
        }
    }
}